#include "Widget.h"

#include <QApplication>

#include <QSettings>

QTranslator * trans = nullptr;

QString readSetting();

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    trans=new QTranslator;
    QString curLang=readSetting(); //读取语言设置
    if (curLang=="EN")
        trans->load(":/English.qm") ;
    else
        trans->load(":/SimplifiedChinese.qm") ;
    a.installTranslator (trans) ;

    Widget w;
    w.show();
    return a.exec();
}

QString readSetting()
{
    //从注册表读取上次设置的语言
    QString organization="BFSM-Qt";
    QString appName="language Examples";
    QSettings settings(organization, appName);

    QString Language=settings.value("Language", "EN").toString();

    return Language;
}
